package cn.geminis.lowcode.compiler.code;

import cn.geminis.lowcode.compiler.util.JdkTreeMakerUtils;
import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.ModifiersTree;

import javax.lang.model.element.Element;
import java.util.Arrays;

/**
 * @author puddi
 */
public class LcModifier extends AbstractCode<ModifiersTree, Element> {
    private final LcAnnotation[] annotations;
    private final long flags;

    public LcModifier(long flags, LcAnnotation... annotations) {
        this.flags = flags;
        this.annotations = annotations;
    }

    @Override
    protected ModifiersTree createJdkTree() {
        return JdkTreeMakerUtils.modifiers(
                this.flags,
                Arrays.stream(this.annotations).map(LcAnnotation::getJdkTree).toArray(AnnotationTree[]::new)
        );
    }

    @Override
    protected Element createJdkElement() {
        throw new UnsupportedOperationException();
    }
}
